﻿// -----------------------------------------------------------------------
// <copyright file="DXRibbonControlAdapter.cs" company="ABC">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Abc.Desktop.Adapters
{
    using System.Collections.Specialized;

    using DevExpress.Xpf.Ribbon;

    using Microsoft.Practices.Prism.Regions;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class DxRibbonControlAdapter : RegionAdapterBase<RibbonControl>
    {
        public DxRibbonControlAdapter(IRegionBehaviorFactory regionBehaviorFactory)
            : base(regionBehaviorFactory)
        {
        }

        #region RegionAdapterBase MEMBERS
        protected override void Adapt(IRegion region, RibbonControl regionTarget)
        {
            region.Views.CollectionChanged += (sender, e) =>
            {
                switch (e.Action)
                {
                    case NotifyCollectionChangedAction.Add:
                        foreach (RibbonPage page in e.NewItems)
                        {
                            regionTarget.SelectedPage.PageCategory.Pages.Add(page);
                        }

                        break;
                }
            };
        }

        protected override IRegion CreateRegion()
        {
            return new Region();
        }
        #endregion
    }
}
